//
//  activityViewController.m
//  UI13-豆瓣电影
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "activityViewController.h"
#import "MyTableViewCell.h"
#import "ActivityModel.h"
#import "UIImageView+WebCache.h"
@interface activityViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain)UITableView *tableView;
@property (nonatomic, retain)NSMutableArray *dataArr;
@end

@implementation activityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"活动";
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg"] forBarMetrics:UIBarMetricsDefault];
    
    
    self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    _tableView.delegate =self;
    _tableView.dataSource =self;
    [self.view addSubview:_tableView];
    [_tableView registerClass:[MyTableViewCell class] forCellReuseIdentifier:@"cell"];
  
    
    
    [self data];
    
    
}

- (void)data
{

    NSString *path = [[NSBundle mainBundle]pathForResource:@"activity" ofType:@"plist"];
    NSArray *arr = [NSArray arrayWithContentsOfFile:path];
    self.dataArr =  [ActivityModel modelHandWithArray:arr];

}




- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return _dataArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    ActivityModel *m = _dataArr[indexPath.row];
    cell.title.text = m.title;

    cell.begin.text = [[[m.begin_time substringWithRange:NSMakeRange(5,11)] stringByAppendingString:@" -- "] stringByAppendingString:[m.end_time substringWithRange:NSMakeRange(5, 11)]];
    cell.address.text = m.address;
    cell.category.text = [@"类型:  " stringByAppendingString:m.category_name];
    cell.wisher.text =[@"感兴趣:  " stringByAppendingString: m.wisher_count.stringValue];
    cell.participant.text = [@"参加:  " stringByAppendingString: m.participant_count.stringValue];
    
    [cell.photo sd_setImageWithURL:[NSURL URLWithString:m.image]];
    
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 280;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
